﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;

namespace KerriganBlog
{
    public partial class Acceuil : System.Web.UI.Page
    {


        protected void Page_Load(object sender, EventArgs e)
        {
            DisplayArticle();
        }


        public void DisplayArticle() {

            if (!Page.IsPostBack)
            {


                using (ServiceProxy Srv = new ServiceProxy())
                {


                    //PagedDataSource page = new PagedDataSource();
                    //page.AllowCustomPaging = true;
                    //page.AllowPaging = true;
                    //page.DataSource = Srv.Service.GetArticleToDisplay();
                    //page.PageSize = 10;

                    GridView1.DataSource = Srv.Service.GetArticleToDisplay();
                    GridView1.DataBind();
                    //Repeater1.DataSource = page;
                    //Repeater1.DataBind();


                }


            }
        
        }


        protected void GridView1_Paging(object sender, GridViewPageEventArgs e)
         {
             
             GridView1.PageIndex = e.NewPageIndex ;
             RefreshDataGrid();
         }


        protected void RefreshDataGrid()
        {
            this.GridView1.DataSource = null;
            using (ServiceProxy Srv = new ServiceProxy())
            {

                GridView1.DataSource = Srv.Service.GetArticleToDisplay();
                GridView1.DataBind();

            }

        }

    
    }
}